package com.yishusmt.mobsmt.controller;

import com.yishusmt.mobsmt.check.DataCheck;
import com.yishusmt.mobsmt.dto.base.Result;
import com.yishusmt.mobsmt.dto.request.ResetPasswordReq;
import com.yishusmt.mobsmt.service.PasswordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author zhangyi
 * @date 2018/8/16 11:04
 */
@RestController
@RequestMapping("/search")
public class PasswordController {

    @Resource
    private PasswordService passwordService;


    /**
     * 发送信息
     *
     * @param style
     * @param contact
     * @return
     */
    @GetMapping("/findPassword/{style}/{contact}")
    @ApiOperation(value = "发送信息",httpMethod = "GET")
    public Result findPassword(@PathVariable("style") String style, @PathVariable("contact") String contact){
        return passwordService.findPassword(style,contact);
    }


    /**
     * 重置密码
     *
     * @return
     */
    @PostMapping("/editPassword")
    @ApiOperation(value = "修改密码",httpMethod = "POST")
    public Result resetPassword(@RequestBody ResetPasswordReq resetPasswordReq){
        DataCheck.isNull(resetPasswordReq);
        return passwordService.resetPassword(resetPasswordReq);
    }
}
